<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveRecord::Timestamp</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActiveRecord::Timestamp 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/activerecord/lib/active_record/timestamp_rb.html">activerecord/lib/active_record/timestamp.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<h1 id="label-Active+Record+Timestamp">Active Record <a href="Timestamp.html">Timestamp</a></h1>

<p>Active Record automatically timestamps create and update operations if the
table has fields named <code>created_at/created_on</code> or
<code>updated_at/updated_on</code>.</p>

<p>Timestamping can be turned off by setting:</p>

<pre>config.active_record.record_timestamps = false</pre>

<p>Timestamps are in the local timezone by default but you can use UTC by
setting:</p>

<pre>config.active_record.default_timezone = :utc</pre>

<h2 id="label-Time+Zone+aware+attributes"><a href="../Time.html">Time</a> Zone aware attributes</h2>

<p>By default, <a href="Base.html">ActiveRecord::Base</a> keeps all the
datetime columns time zone aware by executing following code.</p>

<pre>config.active_record.time_zone_aware_attributes = true</pre>

<p>This feature can easily be turned off by assigning value <code>false</code>
.</p>

<p>If your attributes are time zone aware and you desire to skip time zone
conversion to the current <a
href="../Time.html#method-c-zone">Time.zone</a> when reading certain
attributes then you can do following:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Topic</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">skip_time_zone_conversion_for_attributes</span> = [:<span class="ruby-identifier">written_on</span>]
<span class="ruby-keyword">end</span>
</pre>

    </div>
  


  


  
  


  


  

  



  

    

    

    


    


    <!-- Methods -->
              </div>

    </div>
  </body>
</html>    